package com.fl.message.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.fl.message.constant.MessageConstant.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: fulin
 * @Date: 2022/12/27/14:59
 * @Description:
 */
@Configuration
public class RabbitmqConfig {

    @Bean("queue")
    public Queue queue(){
        return new Queue(PUBLIC_QUEUE_MESSAGE,true,false,false);
    }

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange(PUBLIC_EXCHANGE_MESSAGE);
    }

    @Bean
    public Binding binding(@Qualifier("queue") Queue queue,FanoutExchange fanoutExchange){
        return BindingBuilder.bind(queue).to(fanoutExchange);
    }


}
